﻿using System.Reflection;

namespace NotMyself.Oxite.Data.LinqToNHibernateProvider.Tests.Utility
{
    public static class ReflectionHelper
    {
        public static void SetPrivateField(object item, string fieldName, object value)
        {
            item.GetType()
                .GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance)
                .SetValue(item, value);
        }

        public static void SetStaticField<T>(string fieldName, object value)
        {
            typeof (T).GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Static)
                .SetValue(null, value);
        }
    }
}